/**********************************
 * class Rbac
 *******************/
(function(){

    var Rbac = window.Rbac = function( subject )
    {
        // 注册(观察者)
        if( subject ){
            subject.attach(this);
        }

        // 命令对象
        this.cmdUser = new CmdBuilder( "rbac","user","null" );
        this.cmdRole = new CmdBuilder( "rbac","role","null" );
        this.cmdPerm = new CmdBuilder( "rbac","perm","null" );

        // 功能模块
        // this.user = new Users("execute.aspx","rbac","user","");
        // this.role = new Roles("execute.aspx","rbac","role","");
        // this.perm = new Permissions("execute.aspx","rbac","permission","");

    }

    Rbac.fn = Rbac.prototype =
    {
        listening : function( cmd )
        {
            if(cmd.subsys != this.cmdUser.subsys ){  return false;    }

            var dispArea = Rbac.ui.init();
            dispArea.content.append("<h1>Rbac</h1>");

            // this.user.listening();
            // this.role.listening();
            // this.perm.listening();
            this.logout(cmd);

        },


        // 注销登录
        logout : function( cmd )
        {
            if(cmd.module != "rbac/logout"){  return false;  }

            $.get( "execute.aspx?cmd=rbac/logout", function( dat ){
                alert(dat);
                location.href = "login.aspx?continue=console.aspx";
            });
        }
    };

    // Ui
    Rbac.ui = {
        topToolbar: "",
        content: "",
        bottomToolbar: "",

        init : function(){
            this.topToolbar = App.ui.toolbarWrap.clone(true);
            this.content = App.ui.contentWrap.clone(true);
            this.bottomToolbar =this.topToolbar.clone(true);

            App.ui.content.empty()             //主显示区域
                  .append(this.topToolbar)     //工具显示区域
                  .append(this.content)        //内容显示区域
                  .append(this.bottomToolbar);

            this.topToolbar.append(App.ui.btnReturn.clone(true));       //填充顶部工具
            this.bottomToolbar.append(App.ui.btnReturn.clone(true));    //填充底部工具条

            return this;
        }
    };

})();